/** @file               sw_crypt.h
 *  @copyright          Copyright (C) 2006-2026 flyfish (tenggui_fu@126.com)
 *  @brief              This file is part of swallow library
 *  @author             $Author: Thinkpad $
 *  @version            $Rev: 410 $
 *  @date               $Date: 2016-12-28 11:38:48 +0800 (周三, 28 12月 2016) $
 */
 
#ifndef __SW_CRYPT_H__
#define __SW_CRYPT_H__

#ifdef __cplusplus
extern "C" {
#endif

typedef enum _SW_CIPHER_TYPE
{
    SW_CIPHERT_AES,
    SW_CIPHERT_DES,
    SW_CIPHERT_DES3,
    SW_CIPHERT_WJC,
    SW_CIPHERT_NUM
}SW_CIPHER_TYPE;

typedef enum _SW_HASH_TYPE
{
    SW_HASHT_MD5,
    SW_HASHT_SHA1,
    SW_HASHT_SHA224,
    SW_HASHT_SHA256,
    SW_HASHT_SHA384,
    SW_HASHT_SHA512,
    SW_HASHT_CRC32,
    SW_HASHT_CRC32B,
    SW_HASHT_NUM
}SW_HASH_TYPE;

SW_API SW_RET SW_InitCryptAPI(SW_VOID);
SW_API SW_RET SW_RunCryptAPI(SW_VOID);
SW_API SW_RET SW_StopCryptAPI(SW_VOID);
SW_API SW_RET SW_ExitCryptAPI(SW_VOID);
SW_API const SW_CHAR *SW_CipherTypeToStr(SW_CIPHER_TYPE type);
SW_API SW_CIPHER_TYPE SW_StrToCipherType(const SW_CHAR *pStr);
SW_API const SW_CHAR *SW_HashTypeToStr(SW_HASH_TYPE type);
SW_API SW_HASH_TYPE SW_StrToHashType(const SW_CHAR *pStr);
SW_API SW_RET SW_CipherEncrypt(SW_VOID *pDstBuf, SW_UINT32 *pDstBufLen, const SW_VOID *pSrcBuf, SW_UINT32 srcBufLen, const SW_VOID *pKey, SW_UINT32 keyLen, SW_CIPHER_TYPE type);
SW_API SW_RET SW_CipherDecrypt(SW_VOID *pDstBuf, SW_UINT32 *pDstBufLen, const SW_VOID *pSrcBuf, SW_UINT32 srcBufLen, const SW_VOID *pKey, SW_UINT32 keyLen, SW_CIPHER_TYPE type);
SW_API SW_RET SW_HashEncrypt(SW_VOID *pDstBuf, SW_UINT32 *pDstBufLen, const SW_VOID *pSrcBuf, SW_UINT32 srcBufLen, SW_HASH_TYPE type);
SW_API SW_RET SW_Base64Encode(SW_VOID *pDstBuf, SW_UINT32 *pDstBufLen, const SW_VOID *pSrcBuf, SW_UINT32 srcBufLen);
SW_API SW_RET SW_Base64Decode(SW_VOID *pDstBuf, SW_UINT32 *pDstBufLen, const SW_VOID *pSrcBuf, SW_UINT32 srcBufLen);
SW_API SW_RET SW_GetUuid(SW_VOID *pUuid, SW_UINT32 *pUuidLen);

#ifdef __cplusplus
}
#endif

#endif
